package com.moji.controller.api;


import com.moji.common.base.ApiResult;
import com.moji.entity.MjSolution;
import com.moji.entity.MjStatistics;
import com.moji.entity.dto.QueryStatisticsDto;
import com.moji.entity.vo.StatisticsVo;
import com.moji.service.MjSolutionService;
import com.moji.service.MjStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 数据统计表 前端控制器
 * </p>
 *
 * @author ccl
 * @since 2024-11-06
 */
@RestController
@RequestMapping("api/mjStatistics")
@Api(tags = "数据统计相关接口", value = "数据统计相关接口")
public class MjStatisticsController {

    @Resource
    private MjStatisticsService mjStatisticsService;

    @PostMapping("/hits")
    @ApiOperation(value = "点击量统计",response = StatisticsVo.class)
    public ApiResult<StatisticsVo> hits(@RequestBody QueryStatisticsDto dto) {
        return ApiResult.ok(this.mjStatisticsService.hits(dto));
    }


    @PostMapping("/visitRecord")
    @ApiOperation(value = "访客量统计",response = StatisticsVo.class)
    public ApiResult<StatisticsVo> visitPerson(@RequestBody QueryStatisticsDto dto) {
        return ApiResult.ok(this.mjStatisticsService.visitPerson(dto));
    }

    @PostMapping("/pvUv")
    @ApiOperation(value = "pv和uv统计",response = StatisticsVo.class)
    public ApiResult<StatisticsVo> pvUv(@RequestBody QueryStatisticsDto dto) {
        return ApiResult.ok(this.mjStatisticsService.pvUv(dto));
    }

    @GetMapping("/selectTitle")
    @ApiOperation(value = "title下拉框",response = StatisticsVo.class)
    public ApiResult<List<Map<String,String>>> selectTitle(String menuType) {
        return ApiResult.ok(this.mjStatisticsService.selectTitle(menuType));
    }
    @PostMapping("/countOver3s")
    @ApiOperation(value = "停留时长超过3s统计",response = StatisticsVo.class)
    public ApiResult<Map<String,Long>> countOver3s(@RequestBody QueryStatisticsDto dto) {
        return ApiResult.ok(this.mjStatisticsService.countOver3s(dto));
    }
}

